package top.wenzz.manage.system.config;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.web.ErrorAttributes;
import org.springframework.boot.autoconfigure.web.ErrorViewResolver;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import top.wenzz.commons.web.ErrorController;

import java.util.List;

/**
 * Created by zhongty on 2017/7/28.
 */
@Configuration
public class WebMvcConfig {

    @Bean
    public ErrorController errorController(ErrorAttributes errorAttributes, ServerProperties serverProperties,
                                           ObjectProvider<List<ErrorViewResolver>> errorViewResolversProvider) {
        return new ErrorController(errorAttributes, serverProperties.getError(),
                errorViewResolversProvider.getIfAvailable());
    }

}
